package com.iplant.wms.service.po.hr;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.select.DBJoinMultiSelect;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.wms.service.basicenum.wms.WMSStockAlarmStatus;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 库存预警
 *
 * @author ShrisJava
 */
@DBBasePO(TableName = "wms_stock_alarm", Name = false, Active = false, CheckName = {
        "Code", "FactoryID,OrderID,StoreID,AlarmDate", "FactoryID,OrderNo,StoreID,AlarmDate"},
        Schemas = DBSchemas.WMS, CodeAuto = true, CodePrefix = "SAM{yyMMdd}", CodeNum = 3)
public class WMSStockAlarmHR extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField(Update = false)
    public int FactoryID = 0;

    @DBJoin(name = "Code", tableName = "fmc_factory", tableAsName = "f1",
            Schemas = DBSchemas.Basic, MainTableField = "FactoryID")
    public String FactoryCode = "";

    @DBJoin(name = "Name", tableName = "fmc_factory", tableAsName = "f1",
            Schemas = DBSchemas.Basic, MainTableField = "FactoryID")
    public String FactoryName = "";

    @DBCondition
    @DBField(Update = false)
    public int OrderID = 0;

    @DBCondition
    @DBField(Update = false)
    public String OrderNo = "";


    @DBCondition
    @DBField
    public int StoreID = 0;

    @DBJoin(name = "Name", tableName = "wms_store", tableAsName = "s4",
            JoinMode = DBJoin.DBJoinMode.Left,
            Schemas = DBSchemas.WMS, MainTableField = "StoreID")
    public String StoreName = "";
    @DBJoin(name = "Code", tableName = "wms_store", tableAsName = "s4",
            JoinMode = DBJoin.DBJoinMode.Left,
            Schemas = DBSchemas.WMS, MainTableField = "StoreID")
    public String StoreCode = "";
    /**
     * 预警日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "AlarmDateStart", ParamName2 = "AlarmDateEnd")
    @DBField(Update = false)
    public Calendar AlarmDate = Calendar.getInstance();

    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int Status = 0;

    public String StatusText = "";

    @DBJoinMultiSelect(OutTableField = "StockAlarmID", ItemClazz = WMSStockAlarmItemHR.class)
    public List<WMSStockAlarmItemHR> AlarmItemList=new ArrayList<>();


    @JsonProperty("FactoryID")
    public int getFactoryID() {
        return FactoryID;
    }

    public void setFactoryID(int factoryID) {
        FactoryID = factoryID;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("StoreID")
    public int getStoreID() {
        return StoreID;
    }

    public void setStoreID(int storeID) {
        StoreID = storeID;
    }

    @JsonProperty("StoreName")
    public String getStoreName() {
        return StoreName;
    }

    public void setStoreName(String storeName) {
        StoreName = storeName;
    }

    @JsonProperty("StoreCode")
    public String getStoreCode() {
        return StoreCode;
    }

    public void setStoreCode(String storeCode) {
        StoreCode = storeCode;
    }

    @JsonProperty("AlarmDate")
    public Calendar getAlarmDate() {
        return AlarmDate;
    }

    public void setAlarmDate(Calendar alarmDate) {
        AlarmDate = alarmDate;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText= WMSStockAlarmStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }
}
